// 预约
const sequelize = require( '../config.js')
const { DataTypes } = require('sequelize')

const appoint = sequelize.define('appoint', {
    Id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true,
    },
    user_id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        comment: '会员用户ID',
        references:{
            model:'memberinfos',
            key:'user_id'
        }
    },
    service_id: {  // 改名为service_id以保持一致性
        type: DataTypes.INTEGER,
        allowNull: false,
        comment: "预约的产品ID",
        references:{
            model: 'productServices', // 确保这个表名与数据库中的表名一致
            key: 'Id'
        }
    },
    merchant_id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        comment: '预约的商家ID'
    },
    appointment_time: {
        type: DataTypes.STRING,
        comment: '预约时间'
    },
    appoint_state: {
        type: DataTypes.STRING,
        comment: "预约状态 1 预约  2到店  3结束"
    },
    paly_state: {
        type: DataTypes.STRING,
        comment: "支付方式 1 微信  2次卡  3超划算"
    },
});

  (async ()=>{
	await appoint.sync({alter:true});
  })()
  module.exports = appoint
  